<?php
namespace ImiApp\ApiServer\Controller;

use Imi\Controller\HttpController;
use Imi\Server\Route\Annotation\Route;
use Imi\Server\Route\Annotation\Action;
use Imi\Server\Route\Annotation\Controller;

/**
 * @Controller
 */
class TestController extends HttpController
{
    /**
     * @Action
     * @Route(url="/test", ignoreCase=true)
     *
     * @return void
     */
    public function test()
    {
        return [
            'data'  =>  'test',
        ];
    }

    /**
     * @Action
     * @Route(url="/article/{id}")
     *
     * @return void
     */
    public function article($id)
    {
        return [
            'id'    =>  $id,
        ];
    }

    /**
     * @Action
     * @Route(url="/article/delete", method={"POST"})
     *
     * @return void
     */
    public function deleteArticle()
    {
        return [
            'data'  =>  111,
        ];
    }

    /**
     * @Action
     * @Route(url="/domain", domain="127.0.0.1:8080")
     *
     * @return void
     */
    public function domain()
    {
        return [
            'data'    =>  'domain',
        ];
    }

    /**
     * @Action
     * @Route(url="/testGet", paramsGet="name=imi")
     *
     * @return void
     */
    public function testGet($name)
    {
        return [
            'name'  =>  $name,
        ];
    }

    /**
     * @Action
     * @Route(url="/testPost", paramsPost="birthday!=19260817")
     *
     * @return void
     */
    public function testPost($birthday)
    {
        return [
            'birthday'  =>  $birthday,
        ];
    }

    /**
     * @Action
     * @Route(url="/ct", requestMime="application/json")
     *
     * @return void
     */
    public function ct()
    {
        return [
            'data'  =>  'ct',
        ];
    }

}
